#!/usr/bin/env python
# encoding: utf-8
"""
GeneratorTest.py

Tests for the Generator class.

Created by Alakazam on 2008-05-26.
Copyright (c) 2008. All rights reserved.
"""

import unittest
from Generator import Generator

class GeneratorTest(unittest.TestCase):
  def setUp(self):
    # Number of points to use for testing
    self.n       = 1000
    self.dim     = 3
    self.highDim = 60
  
  def testNotimplemented(self):
    self.assertRaises(NotImplementedError, Generator, generator="NotImplemented")
  
  def testGaussian(self):
    generator = Generator(generator="Gaussian", n=self.n, dim=self.dim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testSwissRoll(self):
    generator = Generator(generator="SwissRoll", n=self.n, dim=self.dim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testSwissHole(self):
    generator = Generator(generator="SwissHole", n=self.n, dim=self.dim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testCornerPlanes(self):
    generator = Generator(generator="CornerPlanes", n=self.n, dim=self.dim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testToroidalHelix(self):
    generator = Generator(generator="ToroidalHelix", n=self.n, dim=self.dim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def test3DClusters(self):
    generator = Generator(generator="3DClusters", n=self.n, dim=self.dim, param=10)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testNoise(self):
    generator = Generator(generator="Gaussian", n=self.n, dim=self.dim, noise=1)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.dim))
  
  def testSwissRollHighDim(self):
    generator = Generator(generator="SwissRoll", n=self.n, dim=self.highDim)
    
    generator.generateData()
    
    self.assertEqual(generator.data.shape, (self.n, self.highDim))

if __name__ == '__main__':
  unittest.main()
